let vm = new Vue({
    el: '#main-container',
    data:{
        pageInfo:{
            current:1,
            pageSize: 5
        },
        demand:{

        }
    },
    methods: {
        select: function (current, pageSize) {
            //分页查询返回信息放入pageInfo
            axios({
                url:`/manager/demand/select/${current}/${pageSize}`
            }).then(response=>{
                this.pageInfo=response.data.data;
            })
        },
        toUpdate(demandId){
            axios({
                url:'/manager/demand/selectOne',
                params: {demandId:demandId}
            }).then(response=>{
                if (response.data.code!=200) {
                    layer.msg(response.data.msg); // 弹出提示框
                    return;
                }
                layer.demand = response.data.data;
                console.log(layer);
                //打开layer的所在的页面
                layer.open({
                    type:2,//类型：0信息框  1 页面层  2 iframe层  3 加载层  4 tips层
                    title:'更新服务需求',
                    content: '/manager/demand/demand-update.html',
                    area: ['60%','80%'],
                    end: ()=>{
                        this.select(this.pageInfo.current,this.pageInfo.pageSize);
                    }
                })
            });
        },
        toDetail(demandId){
            axios({
                url:'/manager/demand/selectOne',
                params: {demandId:demandId}
            }).then(response=>{
                if (response.data.code!=200) {
                    layer.msg(response.data.msg); // 弹出提示框
                    return;
                }
                layer.demand = response.data.data;
                console.log(layer);
                //打开layer的所在的页面
                layer.open({
                    type:2,//类型：0信息框  1 页面层  2 iframe层  3 加载层  4 tips层
                    title:'查看服务需求详情',
                    content: '/manager/demand/demand-detail.html',
                    area: ['60%','80%'],
                    end: ()=>{
                        this.select(this.pageInfo.current,this.pageInfo.pageSize);
                    }
                })
            });
        }
    },
    created: function () {
        this.select(1, this.pageInfo.pageSize);
    }
});